//
//  ZMainTabBarViewController.m
//  OC-weibo
//
//  Created by zero on 17/3/19.
//  Copyright © 2017年 zero. All rights reserved.
//

#import "ZMainTabBarViewController.h"
#import "ZMainNavigationController.h"
#import "ZHomeTableViewController.h"
#import "ZMessageTableViewController.h"
#import "ZDiscoverTableViewController.h"
#import "ZProfileTableViewController.h"
#import "ZTabBar.h"

@interface ZMainTabBarViewController ()

@end

@implementation ZMainTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor z_colorWithHex:0xf5f5f9];
    
    ZTabBar *tabbar = [[ZTabBar alloc] init];
    
    tabbar.zTabBarBlocl = ^{
        
        NSLog(@"加号按钮被点击了");
    };
    
    [self setValue:tabbar forKey:@"tabBar"];
    
    self.viewControllers = [self getChildViewControllers];
    
   
}

#pragma mark
#pragma mark - 创建控制器
- (NSArray *)getChildViewControllers{
    
    NSMutableArray *tempArray = [NSMutableArray array];
    
    [tempArray addObject:[self getChildViewControllerWithVC:[[ZHomeTableViewController alloc] init] andTitle:@"首页" andImageName:@"tabbar_home"]];
    
    [tempArray addObject:[self getChildViewControllerWithVC:[[ZMessageTableViewController alloc] init] andTitle:@"消息" andImageName:@"tabbar_message_center"]];
    
    [tempArray addObject:[self getChildViewControllerWithVC:[[ZDiscoverTableViewController alloc] init] andTitle:@"发现" andImageName:@"tabbar_discover"]];
    
    [tempArray addObject:[self getChildViewControllerWithVC:[[ZProfileTableViewController alloc] init] andTitle:@"我的" andImageName:@"tabbar_profile"]];
    
    
    return tempArray.copy;
}

#pragma mark
#pragma mark - 创建控制器
- (UIViewController *)getChildViewControllerWithVC:(UIViewController *)vc andTitle:(NSString *)title andImageName:(NSString *)imageName{
    
    
    vc.title = title;
    vc.tabBarItem.image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    vc.tabBarItem.selectedImage = [[UIImage imageNamed:[NSString stringWithFormat:@"%@_selected",imageName]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
//    [vc.tabBarItem setTitleTextAttributes:(NSForegroundColorAttributeName,[UIColor orangeColor]) forState:UIControlStateSelected];
    
    return [[ZMainNavigationController alloc] initWithRootViewController:vc];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
